﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Valve.VR;

public class Ban4GetMyMoveAction : MonoBehaviour
{
    public SteamVR_Action_Vector2 moveAction =
        SteamVR_Input.GetAction<SteamVR_Action_Vector2>("platformer", "Move");

    public SteamVR_Action_Boolean jumpAction =
        SteamVR_Input.GetAction<SteamVR_Action_Boolean>("platformer", "Jump");

    public SteamVR_Action_Boolean grabAction =
        SteamVR_Input.GetAction<SteamVR_Action_Boolean>("platformer", "GrabPinch");

    void Update()
    {
//         if (moveAction != null && moveAction.GetChanged(SteamVR_Input_Sources.Any))
//         {
//             Vector2 pos = moveAction.GetAxis(SteamVR_Input_Sources.Any);
//             Debug.Log("移动的坐标是：" + pos);
//         }

//         if (jumpAction != null && jumpAction.GetStateDown(SteamVR_Input_Sources.Any))
//         {
//             Debug.LogWarning("手柄的触摸屏被按下");
//         }
// 
//         if (grabAction != null && grabAction.GetStateDown(SteamVR_Input_Sources.Any))
//         {
//             Debug.LogError("手柄的扳机被按下");
//         }
    }

    /// <summary>
    /// 获得手柄当前移动动作的返回值.
    /// </summary>
    /// <returns></returns>
    public Vector2 GetMoveAxis()
    {
        Vector2 pos = Vector2.zero;
        if (moveAction != null && moveAction.GetChanged(SteamVR_Input_Sources.Any))
        {
            pos = moveAction.GetAxis(SteamVR_Input_Sources.Any);
        }
        return pos;
    }
}
